#include "clientinfo.h"

ClientInfo::ClientInfo(const QString &name, QWidget *parent)
    : QWidget(parent),
      mLabelName(new QLabel(name)), mLabelData(new QLabel()),
      mBtnDisconnect(new QPushButton("断开"))
{
    mLabelName->setMinimumWidth(10);
    mLabelData->setStyleSheet("color: rgb(32, 32, 223);");
    mLabelData->setText("0 Bytes");

    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(mLabelName);
    layout->addStretch();
    layout->addWidget(mLabelData);
    layout->addWidget(mBtnDisconnect);
    setLayout(layout);

    connect(mBtnDisconnect, SIGNAL(clicked()), this, SIGNAL(disconnectRequested()));
}

void ClientInfo::increaseData(int value) {
    data += value;
    mLabelData->setText(GetFileSize(data));
}
